//
//  NurseService.m
//  Nurse
//
//  Created by 夏 申频 on 14-2-16.
//  Copyright (c) 2014年 Honeywell. All rights reserved.
//

#import "NurseService.h"

NSString* const PROCEDUETWD= @"DY_INE_TWD";
NSString* const PRODUCEBEDSFORTW = @"DY_OUT_TW";
NSString* const PRODUCEBEDSFORHX = @"DY_OUT_HX";
NSString* const PRODUCEBEDSFORXL = @"DY_OUT_XL";
NSString* const PRODUCEBEDSFORMB = @"DY_OUT_MB";
NSString* const PRODUCEBEDSFORXY = @"DY_OUT_XY";
NSString* const PRODUCEBEDSFORBQCODE = @"DY_Code_BQ";
NSString* const PRODUCEBEDSFORKS = @"DY_Code_KS";
NSString* const PRODUCEBEDSFORCW = @"DY_Code_CW";
NSString* const PROCEDUEZC = @"DY_INS_ZC";
NSString* const PROCEDUESZ = @"DY_INE_SZ";
NSString* const PROCEDUEOUTSZ = @"DY_OUT_SZ";

@interface NurseService()
@property (nonatomic,strong) NSURL* url;
@end

@implementation NurseService
-(NurseService*)init{
    self= [super init];
    if (self) {
        self.url = [[DataEngine sharedInstance]urlForPath:@"/his/procedure"];
    }
    return self;
}

+(NurseService*) sharedInstance{
    static dispatch_once_t pred = 0;
    __strong static id _sharedObject = nil;
    dispatch_once(&pred, ^{
        _sharedObject = [[NurseService alloc] init];
    });
    return _sharedObject;
}
-(void)queryPatientsTWForPid:(NSString *)pid withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",pid);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORTW;
    request.params = @{@"住院号":pid};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}

-(void)queryWard:(NSString *)tj withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",tj);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORBQCODE;
    request.params = @{@"科室":tj};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}
-(void)queryDepartment:(NSString *)tj withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",tj);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORKS;
    request.params = @{@"科室":tj};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}


-(void)querySZ:(NSString *)tj withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",tj);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PROCEDUEOUTSZ;
    request.params = @{@"内容":tj};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}



-(void)queryInsSZ:(NSString *)tj withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",tj);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PROCEDUESZ;
    request.params = @{@"内容":tj};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}


-(void)queryBednumber:(NSString *)tj withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",tj);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORCW;
    request.params = @{@"BQ":tj};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}



-(void)queryPatientsHXForPid:(NSString *)pid withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",pid);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORHX;
    request.params = @{@"住院号":pid};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}

-(void)queryPatientsMBForPid:(NSString *)pid withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",pid);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORMB;
    request.params = @{@"住院号":pid};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}

-(void)queryPatientsXLForPid:(NSString *)pid withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",pid);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORXL;
    request.params = @{@"住院号":pid};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}

-(void)queryPatientsXYForPid:(NSString *)pid withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    NSLog(@"zyh=%@",pid);
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName=PRODUCEBEDSFORXY;
    request.params = @{@"住院号":pid};
    request.successHandle = successHandler;
    request.failHandle = failHandler;
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
}
-(void)postSignsWithData:(NSString*)postData withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName = PROCEDUETWD;
    request.params = @{@"内容":postData};
    request.failHandle = failHandler;
    request.successHandle = ^(id result){
        NSLog(@"insert twjl:%@",result);
        
        successHandler(result);
    };
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
    
}

-(void)postZCWithData:(NSString *)postData withSuccessHandler:(SuccessHandler)successHandler andFailHandler:(FailHandler)failHandler{
    ProcedureCallRequest* request = [[ProcedureCallRequest alloc]init];
    request.procedureName = PROCEDUEZC;
    request.params = @{@"内容":postData};
    request.failHandle = failHandler;
    request.successHandle = ^(id result){
        NSLog(@"insert twjl:%@",result);
        
        successHandler(result);
    };
    [[DataEngine sharedInstance]callProcedure:request forURL:self.url];
    
}
@end
